import React, { useState,useEffect } from 'react'
import { reqgetbanner, reqgetcate, reqgetindexgoods, reqgetnew, reqgetgroupon, reqgetseckill, reqgetcountdown } from '../../http/api'
import Header from '../../components/Header/Header'
import Banner from './components/Banner/Banner'
import Cate from './components/Cate/Cate'
import Goods from './components/Goods/Goods'
import NewComers from './components/NewComers/NewComers'
import Group from './components/Group/Group'
// import SecKill from './components/SecKill/SecKill'


const Home = ()=> {
  const[cate,setCate] = useState([]);
  const[banner,setBanner] = useState([])
  const [goods, setGoods] = useState([]);
  const [n, setn] = useState(0);
  const [newcomers,setNewcomers] = useState([])
  const [group,setGroup] = useState([])

  useEffect(()=>{
    //请求分类
    reqgetcate().then((res)=>{
      setCate(res.data.list)
    })
    //请求banner
    reqgetbanner().then((res) => {
      setBanner(res.data.list);
    });
    //请求商品
    reqgetindexgoods().then((res) => {
      setGoods(res.data.list);
    });
    //请求新人专享
    reqgetnew().then((res) => {
      setNewcomers(res.data.list);
    });
    //请求万人团
    
    reqgetgroupon().then((res) => {
      setGroup(res.data.list);
    });



  },[])


 
    return (
      <div>
        {/* 头部 */}
        <Header back title="首页"></Header>
        {/* 搜索 */}
        {/* <ToSearch></ToSearch> */}
        {/* 商品分类 */}
        {/* 秒杀 */}
        {/* <SecKill seckill={seckill} time={time}></SecKill> */}
        <Cate cate={cate}></Cate>
        {/* banner */}
        <Banner banner={banner} ></Banner>
        {/* 新人专享 */}
        <NewComers newcomers={newcomers}></NewComers>
        {/* Goods商品 */}
        <Goods goods={goods}  n={n} onChangeN={(v)=>setn(v)}></Goods>
        {/* 万人团 */}
        <Group group={group}></Group>


      </div>
    )
  }



export default Home;